home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / E / PlayTHX / src / thx-play.asm < prev    next >
Encoding:
Assembly Source File  |  1997-10-07  |  6.1 KB  |  303 lines

  1.     ifd _USE020_
  2.     machine    68020
  3.     endc
  4.  
  5. *--------------------------------------------------------------------------*
  6.     xdef    thxWind_i
  7. thxWind_i
  8.     move.l    4(sp),d0
  9.     movem.l    d3-d7/a2-a6,-(sp)
  10.     move.b    mod_OK(pc),d1
  11.     beq.s    .exit
  12.     move.l    d0,d7
  13.     beq.s    .exit
  14.     bmi.s    .neg
  15.     bsr    THX+thxNextPattern
  16.     bra.s    .exit
  17. .neg    bsr    THX+thxPrevPattern
  18. .exit    movem.l    (sp)+,d3-d7/a2-a6
  19.     rts
  20.  
  21. *--------------------------------------------------------------------------*
  22.     xdef    thxSignalEnd_i
  23. thxSignalEnd_i
  24.     move.b    mod_OK(pc),d0
  25.     beq.s    .nosong
  26.     move.l    4.w,a6
  27.     suba.l    a1,a1
  28.     jsr    -294(a6)    ; _LVOFindTask(a6)
  29.     lea    task(pc),a0
  30.     move.l    d0,(a0)+
  31.     move.l    4(sp),(a0)+
  32.     st.w    (a0)        ; set 'signal enable' _last_
  33. .nosong    rts
  34.  
  35. *--------------------------------------------------------------------------*
  36.     xdef    thxSongEnded
  37. thxSongEnded
  38.     move.l    THX+thxBSS_P(pc),d0
  39.     beq.s    .exit
  40.     move.l    d0,a0
  41.     moveq    #0,d0
  42.     move.b    thx_pSongEnd(a0),d0
  43. .exit    rts
  44.  
  45. *--------------------------------------------------------------------------*
  46.     xdef    thxGetSyncByte
  47. thxGetSyncByte
  48.     move.l    THX+thxBSS_P(pc),d0
  49.     beq.s    .exit
  50.     move.l    d0,a0
  51.     moveq    #0,d0
  52.     move.b    (a0),d0    ; thx_pExternalTiming(a0),d0
  53. .exit    rts
  54.  
  55. *--------------------------------------------------------------------------*
  56.     xdef    thxGetNumSongs
  57. thxGetNumSongs
  58.     move.l    THX+thxBSS_P(pc),d0
  59.     beq.s    .exit
  60.     move.l    d0,a0
  61.     moveq    #0,d0
  62.     move.b    thx_pSubsongs(a0),d0
  63. .exit    rts
  64.  
  65. *--------------------------------------------------------------------------*
  66.     xdef    thxSetSong_i
  67. thxSetSong_i
  68.     bsr.s    thxStop
  69.     bsr.s    thxGetNumSongs
  70.     move.l    4(sp),d1    ; get arg from E
  71.     cmp.l    d0,d1
  72.     bhi.s    .exit
  73.     move.l    d1,d0
  74.     move.b    mod_OK(pc),d1
  75.     beq.s    .exit
  76.     lea    song(pc),a0
  77.     move.w    d0,(a0)
  78.     movem.l    d3-d7/a2-a6,-(sp)
  79.     moveq    #1,d1
  80.     bsr    THX+thxInitSubSong
  81.     movem.l    (sp)+,d3-d7/a2-a6
  82. .exit    rts
  83.  
  84. *--------------------------------------------------------------------------*
  85.     xdef    thxGetVolume
  86. thxGetVolume
  87.     move.l    THX+thxBSS_P(pc),d0
  88.     beq.s    .exit
  89.     move.l    d0,a0
  90.     moveq    #0,d0
  91.     move.b    thx_pMainVolume(a0),d0
  92. .exit    rts
  93.  
  94. *--------------------------------------------------------------------------*
  95.     xdef    thxSetVolume_i
  96. thxSetVolume_i
  97.     move.l    4(sp),d0
  98.     cmp.l    #64,d0
  99.     bhi.s    .exit
  100.     move.l    THX+thxBSS_P(pc),d1
  101.     beq.s    .exit
  102.     move.l    d1,a0
  103.     move.b    d0,thx_pMainVolume(a0)
  104. .exit    rts
  105.  
  106. *--------------------------------------------------------------------------*
  107.     xdef    thxPause
  108. thxPause
  109.     move.l    THX+thxBSS_P(pc),d0
  110.     beq.s    .exit
  111.     move.l    d0,a0
  112.     clr.b    thx_pPlaying(a0)
  113. .exit    rts
  114.  
  115. *--------------------------------------------------------------------------*
  116.     xdef    thxPlay
  117. thxPlay
  118.     move.l    THX+thxBSS_P(pc),d0
  119.     beq.s    .exit
  120.     move.l    d0,a0
  121.     st.b    thx_pPlaying(a0)
  122. .exit    rts
  123.  
  124. *--------------------------------------------------------------------------*
  125.     xdef    thxStop
  126. thxStop
  127.     movem.l    d3-d7/a2-a6,-(sp)
  128.     move.b    mod_OK(pc),d0
  129.     beq.s    .nosong
  130.     lea    dosig(pc),a0
  131.     clr.w    (a0)
  132.     bsr    THX+thxStopSong
  133.     bsr.s    thxPause
  134.     move.l    mod(pc),d0
  135.     beq.s    .nosong
  136.     move.l    d0,a0
  137.     bsr    THX+thxInitModule
  138.     moveq    #0,d0
  139.     lea    song(pc),a0
  140.     move.w    (a0),d0
  141.     moveq    #1,d1        ; don't play immediately
  142.     bsr    THX+thxInitSubSong
  143. .nosong    movem.l    (sp)+,d3-d7/a2-a6
  144.     rts
  145.  
  146. *--------------------------------------------------------------------------*
  147.     xdef    thxInit_i
  148. thxInit_i
  149.     lea    mod(pc),a0
  150.     move.l    4(sp),(a0)
  151.     lea    mod_OK(pc),a0
  152.     clr.b    (a0)            ; mod is NOT ok until we say so
  153.     lea    song(pc),a0
  154.     clr.w    (a0)
  155.     movem.l    d3-d7/a2-a6,-(sp)    ; 40 bytes onto stack
  156.     move.b    init_OK(pc),d0
  157.     bne.s    .init_d
  158.     moveq    #0,d0
  159.     moveq    #0,d1
  160.     sub.l    a0,a0    ;auto-allocate public (fast)
  161.     sub.l    a1,a1    ;auto-allocate chip
  162.     bsr    THX+thxInitPlayer
  163.     tst.l    d0
  164.     bne    .fail
  165.     lea    init_OK(pc),a0
  166.     st.b    (a0)
  167.  
  168. .init_d    move.l    mod(pc),d0
  169.     beq.s    .nomod
  170.     move.l    d0,a0
  171.     bsr    THX+thxInitModule
  172.     moveq    #0,d0
  173.     moveq    #1,d1        ; don't play immediately
  174.     bsr    THX+thxInitSubSong
  175.  
  176.  
  177. .nomod    move.b    cia_OK(pc),d0
  178.     bne.s    .inimod
  179.     lea    vbcode(pc),a0
  180.     moveq    #0,d0
  181.     bsr    THX+thxInitCIA
  182.     tst.l    d0
  183.     bne.s    .nocia
  184.     lea    cia_OK(pc),a0
  185.     st.b    (a0)
  186.     bra.s    .inimod
  187.  
  188. .nocia    move.b    vb_OK(pc),d0
  189.     bne.s    .inimod
  190.     lea    int(pc),a0
  191.     clr.l    (a0)+
  192.     clr.l    (a0)+
  193.     lea    intcode(pc),a0
  194.     lea    vbcode(pc),a1
  195.     move.l    a1,(a0)
  196.     lea    intname(pc),a0
  197.     lea    vbname(pc),a1
  198.     move.l    a1,(a0)
  199.     moveq    #5,d0
  200.     lea    int(pc),a1
  201.     move.l    4.w,a6
  202.     jsr    -168(a6)    ; _LVOAddIntServer(a6)
  203.     lea    vb_OK(pc),a0
  204.     st.b    (a0)
  205.  
  206. .inimod    move.l    mod(pc),d0
  207.     beq.s    .done
  208.     move.l    d0,a0
  209.     bsr    THX+thxInitModule
  210.     tst.l    d0
  211.     bne.s    .fail
  212.  
  213.     moveq    #0,d0
  214.     moveq    #1,d1
  215.     bsr    THX+thxInitSubSong
  216.  
  217.     lea    mod_OK(pc),a0
  218.     st.b    (a0)
  219.  
  220. .done    moveq    #0,d0
  221.     bra.s    .exit
  222.  
  223. .fail    bsr.s    thxFree
  224.     moveq    #-1,d0
  225. .exit    movem.l    (sp)+,d3-d7/a2-a6
  226.     rts
  227.  
  228. *--------------------------------------------------------------------------*
  229.     xdef    thxFree
  230. thxFree    movem.l    d3-d7/a2-a6,-(sp)    ; 40 bytes onto stack
  231.     bsr    thxStop
  232.  
  233.     move.b    cia_OK(pc),d0
  234.     beq.s    .nocia
  235.     bsr    THX+thxKillCIA
  236.     
  237. .nocia    move.b    vb_OK(pc),d0
  238.     beq.s    .novb
  239.     moveq    #5,d0
  240.     lea    int(pc),a1
  241.     move.l    4.w,a6
  242.     jsr    -174(a6)    ; _LVORemIntServer(a6)
  243.  
  244. .novb    move.b    init_OK(pc),d0
  245.     beq.s    .noinit
  246.     bsr.s    THX+thxKillPlayer
  247.  
  248. .noinit    lea    cia_OK(pc),a2
  249.     clr.l    (a2)        ; clear cia_OK, vb_OK, init_OK and mod_OK
  250.     movem.l    (sp)+,d3-d7/a2-a6
  251.     rts
  252.  
  253. *--------------------------------------------------------------------------*
  254.  
  255. vbcode    movem.l    d0-d7/a0-a6,-(sp)
  256.     move.l    THX+thxBSS_P(pc),a0
  257.     tst.b    thx_pPlaying(a0)
  258.     beq.s    .exit
  259.  
  260.     tst.b    thx_pSongEnd(a0)
  261.     beq.s    .play        ; don't signal if not songend
  262.     move.w    dosig(pc),d0
  263.     beq.s    .play        ; don't signal if dosig=0
  264.     move.l    4.w,a6
  265.     move.l    task(pc),a1
  266.     move.l    signal(pc),d0
  267.     jsr    -324(a6)    ; _LVOSignal(a6)
  268.     lea    dosig(pc),a0
  269.     clr.w    (a0)
  270.  
  271. .play    bsr.s    THX+thxInterrupt
  272. .exit    movem.l    (sp)+,d0-d7/a0-a6
  273.     ori.w    #%100,ccr    ; set Z flag
  274.     rts
  275.  
  276.     include    thx-offsets.i
  277. THX
  278.     ifd    _USE020_
  279.     incbin    thx-replayer020.bin
  280.     else
  281.     incbin    thx-replayer000.bin
  282.     endc
  283.  
  284. cia_OK    dc.b    0    ; int routine is CIA, and is initialised and running
  285. vb_OK    dc.b    0    ; int routine is VBI, and is initialised and running
  286. init_OK    dc.b    0    ; initialisation (memory, etc) is done
  287. mod_OK    dc.b    0    ; module is initialised, play can commence
  288.  
  289. mod    dc.l    0    ; ptr to current module
  290. song    dc.w    0    ; playing song
  291.  
  292. task    dc.l    0    ; ptr to task to signal
  293. signal    dc.l    0    ; signals to send
  294. dosig    dc.w    0    ; true if we should signal sometime, false if not
  295.  
  296. int    dc.l    0,0    ; succ,pred
  297.     dc.b    2,0    ; NT_INTERRUPT,pri=0
  298. intname    dc.l    0,0    ; name, iv_data
  299. intcode    dc.l    0    ; iv_code
  300.  
  301. vbname    dc.b    "Nora Batty's original THX2 player (tm)",0
  302.     cnop    0,4
  303.